/**
 * Learning Backbone
 * -> Syncing Models with Views
 *
 * @author: MPeg [marco(dot)pegoraro(at)gmail(dot)com]
 */

/**
 * This example extends the 001{HelloWorld} configuration adding a rule for the
 * new "models" folder.
 * 
 * Models are the Backbone way to handle data structure leafs.
 * 
 */
require.config({

	baseUrl : './',

	paths : {

		// Libraries
		text : '_libs/require/text',
		jquery : '_libs/jquery/jquery.172',
		jqueryui : '_libs/jquery/jquery-ui-1.8.21.min',
		underscore : '_libs/underscore/underscore.133',
		backbone : '_libs/backbone/backbone.092',
		// Application Places
		view : 'js/views',
		model : 'js/models'

	},

	shim : {
		underscore : {
			exports : '_'
		},
		backbone : {
			deps : [ 'underscore', 'jquery', 'jqueryui' ],
			exports : 'Backbone'
		}
	}

});

/**
 * This is the main module of our app. This example is so simple that does not
 * require an AppView to be correctly handled.
 * 
 * This code block acts as an MVC controller to load and configure sub-module
 * block. These sub-modules are models and views.
 * 
 */

define([

// Frameworks
'jquery',

// Models,
'model/textmenu',

// Views
'view/form_view', 'view/show_view', 'view/slider_view',

// Templates
'text!templates/menu_text_template.html'

], function(

// Frameworks
$,

// Models
MenuTextModel,

// Views
FormView, ShowView, SliderView,

// Templates
MenuTextTemplate

) {

	var menuText = new MenuTextModel;

	// The FormView handle form submission.
	// fetch data form form's field and updates the model.
	var form = new FormView({
		el : $("form"),
		model : menuText
	});

	// Show(x) views display some UI to the app.
	// show(x) belong to the PersonModel instance to display correct data.
	var showMenuText = new ShowView({
		el : $('#menuText'),
		model : menuText,
		template : MenuTextTemplate
	});


});